.class public Llecho/lib/hellocharts/gesture/ChartScroller;
.super Ljava/lang/Object;


# instance fields
.field private scroller:Landroid/support/v4/widget/ScrollerCompat;

.field private scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

.field private surfaceSizeBuffer:Landroid/graphics/Point;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    new-instance v0, Llecho/lib/hellocharts/model/Viewport;

    invoke-direct {v0}, Llecho/lib/hellocharts/model/Viewport;-><init>()V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    new-instance v0, Landroid/graphics/Point;

    invoke-direct {v0}, Landroid/graphics/Point;-><init>()V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    invoke-static {p1}, Landroid/support/v4/widget/ScrollerCompat;->create(Landroid/content/Context;)Landroid/support/v4/widget/ScrollerCompat;

    move-result-object v0

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    return-void
.end method


# virtual methods
.method public computeScrollOffset(Llecho/lib/hellocharts/computator/ChartComputator;)Z
    .locals 4

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    invoke-virtual {v0}, Landroid/support/v4/widget/ScrollerCompat;->computeScrollOffset()Z

    move-result v0

    if-eqz v0, :cond_0

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v0

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    invoke-virtual {p1, v1}, Llecho/lib/hellocharts/computator/ChartComputator;->computeScrollSurfaceSize(Landroid/graphics/Point;)V

    iget v1, v0, Llecho/lib/hellocharts/model/Viewport;->left:F

    invoke-virtual {v0}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v2

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    invoke-virtual {v3}, Landroid/support/v4/widget/ScrollerCompat;->getCurrX()I

    move-result v3

    int-to-float v3, v3

    mul-float/2addr v2, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v3, v3, Landroid/graphics/Point;->x:I

    int-to-float v3, v3

    div-float/2addr v2, v3

    add-float/2addr v1, v2

    iget v2, v0, Llecho/lib/hellocharts/model/Viewport;->top:F

    invoke-virtual {v0}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v0

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    invoke-virtual {v3}, Landroid/support/v4/widget/ScrollerCompat;->getCurrY()I

    move-result v3

    int-to-float v3, v3

    mul-float/2addr v0, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v3, v3, Landroid/graphics/Point;->y:I

    int-to-float v3, v3

    div-float/2addr v0, v3

    sub-float v0, v2, v0

    invoke-virtual {p1, v1, v0}, Llecho/lib/hellocharts/computator/ChartComputator;->setViewportTopLeft(FF)V

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public fling(IILlecho/lib/hellocharts/computator/ChartComputator;)Z
    .locals 9

    const/4 v5, 0x0

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    invoke-virtual {p3, v0}, Llecho/lib/hellocharts/computator/ChartComputator;->computeScrollSurfaceSize(Landroid/graphics/Point;)V

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v1

    invoke-virtual {v0, v1}, Llecho/lib/hellocharts/model/Viewport;->set(Llecho/lib/hellocharts/model/Viewport;)V

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v0, v0, Landroid/graphics/Point;->x:I

    int-to-float v0, v0

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    iget v1, v1, Llecho/lib/hellocharts/model/Viewport;->left:F

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v2

    iget v2, v2, Llecho/lib/hellocharts/model/Viewport;->left:F

    sub-float/2addr v1, v2

    mul-float/2addr v0, v1

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v1

    invoke-virtual {v1}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v1

    div-float/2addr v0, v1

    float-to-int v1, v0

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v0, v0, Landroid/graphics/Point;->y:I

    int-to-float v0, v0

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v2

    iget v2, v2, Llecho/lib/hellocharts/model/Viewport;->top:F

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    iget v3, v3, Llecho/lib/hellocharts/model/Viewport;->top:F

    sub-float/2addr v2, v3

    mul-float/2addr v0, v2

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v2

    invoke-virtual {v2}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v2

    div-float/2addr v0, v2

    float-to-int v2, v0

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    invoke-virtual {v0}, Landroid/support/v4/widget/ScrollerCompat;->abortAnimation()V

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v0

    invoke-virtual {v0}, Landroid/graphics/Rect;->width()I

    move-result v3

    invoke-virtual {p3}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v0

    invoke-virtual {v0}, Landroid/graphics/Rect;->height()I

    move-result v4

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    iget-object v6, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v6, v6, Landroid/graphics/Point;->x:I

    sub-int v3, v6, v3

    add-int/lit8 v6, v3, 0x1

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    iget v3, v3, Landroid/graphics/Point;->y:I

    sub-int/2addr v3, v4

    add-int/lit8 v8, v3, 0x1

    move v3, p1

    move v4, p2

    move v7, v5

    invoke-virtual/range {v0 .. v8}, Landroid/support/v4/widget/ScrollerCompat;->fling(IIIIIIII)V

    const/4 v0, 0x1

    return v0
.end method

.method public scroll(Llecho/lib/hellocharts/computator/ChartComputator;FFLlecho/lib/hellocharts/gesture/ChartScroller$ScrollResult;)Z
    .locals 11

    const/4 v10, 0x0

    const/4 v2, 0x0

    const/4 v1, 0x1

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getMaximumViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v5

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getVisibleViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v6

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v7

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v8

    iget v0, v7, Llecho/lib/hellocharts/model/Viewport;->left:F

    iget v3, v5, Llecho/lib/hellocharts/model/Viewport;->left:F

    cmpl-float v0, v0, v3

    if-lez v0, :cond_4

    move v0, v1

    :goto_0
    iget v3, v7, Llecho/lib/hellocharts/model/Viewport;->right:F

    iget v4, v5, Llecho/lib/hellocharts/model/Viewport;->right:F

    cmpg-float v3, v3, v4

    if-gez v3, :cond_5

    move v3, v1

    :goto_1
    iget v4, v7, Llecho/lib/hellocharts/model/Viewport;->top:F

    iget v9, v5, Llecho/lib/hellocharts/model/Viewport;->top:F

    cmpg-float v4, v4, v9

    if-gez v4, :cond_6

    move v4, v1

    :goto_2
    iget v9, v7, Llecho/lib/hellocharts/model/Viewport;->bottom:F

    iget v5, v5, Llecho/lib/hellocharts/model/Viewport;->bottom:F

    cmpl-float v5, v9, v5

    if-lez v5, :cond_7

    move v5, v1

    :goto_3
    if-eqz v0, :cond_8

    cmpg-float v0, p2, v10

    if-gtz v0, :cond_8

    move v3, v1

    :goto_4
    if-eqz v4, :cond_9

    cmpg-float v0, p3, v10

    if-gtz v0, :cond_9

    move v0, v1

    :goto_5
    if-nez v3, :cond_0

    if-eqz v0, :cond_1

    :cond_0
    iget-object v4, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->surfaceSizeBuffer:Landroid/graphics/Point;

    invoke-virtual {p1, v4}, Llecho/lib/hellocharts/computator/ChartComputator;->computeScrollSurfaceSize(Landroid/graphics/Point;)V

    invoke-virtual {v6}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v4

    mul-float/2addr v4, p2

    invoke-virtual {v8}, Landroid/graphics/Rect;->width()I

    move-result v5

    int-to-float v5, v5

    div-float/2addr v4, v5

    neg-float v5, p3

    invoke-virtual {v6}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v6

    mul-float/2addr v5, v6

    invoke-virtual {v8}, Landroid/graphics/Rect;->height()I

    move-result v6

    int-to-float v6, v6

    div-float/2addr v5, v6

    iget v6, v7, Llecho/lib/hellocharts/model/Viewport;->left:F

    add-float/2addr v4, v6

    iget v6, v7, Llecho/lib/hellocharts/model/Viewport;->top:F

    add-float/2addr v5, v6

    invoke-virtual {p1, v4, v5}, Llecho/lib/hellocharts/computator/ChartComputator;->setViewportTopLeft(FF)V

    :cond_1
    iput-boolean v3, p4, Llecho/lib/hellocharts/gesture/ChartScroller$ScrollResult;->canScrollX:Z

    iput-boolean v0, p4, Llecho/lib/hellocharts/gesture/ChartScroller$ScrollResult;->canScrollY:Z

    if-nez v3, :cond_2

    if-eqz v0, :cond_3

    :cond_2
    move v2, v1

    :cond_3
    return v2

    :cond_4
    move v0, v2

    goto :goto_0

    :cond_5
    move v3, v2

    goto :goto_1

    :cond_6
    move v4, v2

    goto :goto_2

    :cond_7
    move v5, v2

    goto :goto_3

    :cond_8
    if-eqz v3, :cond_b

    cmpl-float v0, p2, v10

    if-ltz v0, :cond_b

    move v3, v1

    goto :goto_4

    :cond_9
    if-eqz v5, :cond_a

    cmpl-float v0, p3, v10

    if-ltz v0, :cond_a

    move v0, v1

    goto :goto_5

    :cond_a
    move v0, v2

    goto :goto_5

    :cond_b
    move v3, v2

    goto :goto_4
.end method

.method public startScroll(Llecho/lib/hellocharts/computator/ChartComputator;)Z
    .locals 2

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scroller:Landroid/support/v4/widget/ScrollerCompat;

    invoke-virtual {v0}, Landroid/support/v4/widget/ScrollerCompat;->abortAnimation()V

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartScroller;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v1

    invoke-virtual {v0, v1}, Llecho/lib/hellocharts/model/Viewport;->set(Llecho/lib/hellocharts/model/Viewport;)V

    const/4 v0, 0x1

    return v0
.end method
